s = input('Введите скобочную последовательность. \n')
ls = []
f = 0

for i in s:
    if i in ('(', '[', '{', '<'):
        ls.append(i)
        # print(ls)
    elif i == ')':
        if len(ls) != 0:
            a = ls.pop(-1)
            if a != '(':
                print('False')
                f = 1
                break
        else:
            print('False')
            f = 1
            break
    elif i == ']':
        if len(ls) != 0:
            a = ls.pop(-1)
            if a != '[':
                print('False')
                f = 1
                break
        else:
            print('False')
            f = 1
            break
    elif i == '}':
        if len(ls) != 0:
            a = ls.pop(-1)
            if a != '{':
                print('False')
                f = 1
                break
        else:
            print('False')
            f = 1
            break
    elif i == '>':
        if len(ls) != 0:
            a = ls.pop(-1)
            if a != '<':
                print('False')
                f = 1
                break
        else:
            print('False')
            f = 1
            break
    # print(ls)

if len(ls) == 0 and f == 0:
    print('True')
elif len(ls) != 0 and f == 0:
    print('False')
